package zwp.example.demo1;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Optional;

@SpringBootTest
public class Demo5Optional {

    @Test
    public void test1(){
        String text = "abc";
        String s = Optional.of(text).orElse("FORM").toUpperCase();
        System.out.println(s);
    }

    @Test
    public void test2(){
        String text = "abc";
        String s = Optional.ofNullable(text).orElse("FORM").toUpperCase();
        System.out.println(s);
    }

    @Test
    public void test3(){
//        LocalDate now = LocalDate.now();
//        LocalDate localDate = now.minusMonths(2);
//        System.out.println(localDate);
//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
//        String format = now.format(formatter);
//        pojoLocalTimeFormat.setTime(now);
//        System.out.println(format);

        Integer a = 1;
        Integer b= null;
        Integer integer = Optional.ofNullable(b).orElse(0);
        Integer i = a - integer;

        System.out.println(i);
    }
}
